/****************************************************
          File Name:mkdir.c
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Mon Dec  8 20:18:29 2014
*****************************************************/

#include "dir.h"

int main(int argc, char **argv)
{
    int res, i;

    if(argc < 2 || strcmp(argv[1],"--help") == 0)
    {
        fprintf(stderr, "%s newdir1 newdir2...\n%s -r newdir"
                "\n\tnewdir1\n\t\tnewdir2\n\t\t\t...\n", argv[0], argv[0]);
        exit(1);
    }

    if(strcmp(argv[1], "-r") == 0)
    {
        i = 2;
        while(i <= argc)
        {
            mkdir(argv[i], 00755);
            chdir(argv[i]);
            i++;
        }
    }
    else
    {
        i=1;
        while(i <= argc)
        {
            mkdir(argv[i], 00755);
            i++;
        }
    }
    return 0;
}
